Skip to content

feat: Optimize parallel processing with optional thread pool scheduling#316

Merged
thomhurst merged 1 commit into
mainfrom
feature/optimized-parallel-processing
Aug 11, 2025
Merged

feat: Optimize parallel processing with optional thread pool scheduling#316
thomhurst merged 1 commit into
mainfrom
feature/optimized-parallel-processing

Conversation

@thomhurst

Copy link
Copy Markdown
Owner
  • Remove unsafe ProcessInParallelUnbounded() method that could block thread pool
  • Add optional scheduleOnThreadPool parameter to ProcessInParallel() methods
  • Default to direct task execution (scheduleOnThreadPool=false) for maximum performance
  • When scheduleOnThreadPool=true, use Task.Run() to protect against blocking code
  • Maintain backward compatibility with existing method signatures
  • Update test to use scheduleOnThreadPool=true for Thread.Sleep scenarios

This change provides maximum parallelism by default while offering safety when needed. Direct execution avoids ~1-2μs Task.Run() overhead per task, improving performance for purely async delegates while still supporting synchronous/blocking code when required.

- Remove unsafe ProcessInParallelUnbounded() method that could block thread pool
- Add optional scheduleOnThreadPool parameter to ProcessInParallel() methods
- Default to direct task execution (scheduleOnThreadPool=false) for maximum performance
- When scheduleOnThreadPool=true, use Task.Run() to protect against blocking code
- Maintain backward compatibility with existing method signatures
- Update test to use scheduleOnThreadPool=true for Thread.Sleep scenarios

This change provides maximum parallelism by default while offering safety when needed.
Direct execution avoids ~1-2μs Task.Run() overhead per task, improving performance
for purely async delegates while still supporting synchronous/blocking code when required.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@thomhurst
thomhurst enabled auto-merge August 11, 2025 19:23
@thomhurst
thomhurst disabled auto-merge August 11, 2025 19:27
@thomhurst
thomhurst merged commit e25fa7b into main Aug 11, 2025
3 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant